package com.tanhua.model.vo;

import com.tanhua.model.db.UserInfo;
import com.tanhua.model.mongo.UserLike;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserLikeVo {

    private String id;
    private String avatar;
    private String nickname;
    private String createDate;

    public static UserLikeVo init(UserInfo userInfo, UserLike likeVo){
        UserLikeVo vo = new UserLikeVo();
        vo.setId(userInfo.getId().toString());
        vo.setAvatar(userInfo.getAvatar());
        vo.setNickname(userInfo.getNickname());
        Date date = new Date(likeVo.getCreated());
        vo.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date));
        return vo;
    }
}
